<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline" style="width: 100px;">
            <select name="type" lay-verify="" >
                <option value="" >所有</option>
                <option value="0" >关键字</option>
                <option value="1" >实际超额</option>
                <option value="2" >预扣超额</option>
            </select>
        </div>
        <div class="layui-inline" style="padding-left: 5px;">
            <input type="text" name="user_name" lay-verify="title" placeholder="Input User Name" autocomplete="off"
                   class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline" style="padding-left: 5px;">
            <input type="text" name="card_num" lay-verify="title" placeholder="Input card_num" autocomplete="off"
                   class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline">
            <input type="text" name="key_name" lay-verify="title" placeholder="Input 关键字" autocomplete="off"
                   class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline">
            <input type="text" name="datetime" id="datetime" placeholder="start_time _ end_time"
                   autocomplete="off" class="layui-input" style="width: 200px;">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            // totalRow: true,
            method: 'post',
            url: "{:url('tranIceUser')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'username',  align: 'left', title: 'UserName',width: 200},
                { field: 'card_status', title: '类型', width:120 ,
                    templet:function (d) {
                        const status=   d.type;
                        var   html  =   '';
                        switch (status) {
                            case 0:
                                html = "<span style='color: green'>关键字</span>";
                                break;
                            case 1:
                                html = "<span style='color: #6c757d'>实际超额</span>";
                                break;
                            case 2:
                                html = "<span style='color: red'>预扣超额</span>";
                                break;
                            // case 4:
                            //     html = "<span style='color: red'>Fraud</span>";
                            //     break;
                        }
                        return html;
                    }
                },
                { field: 'status', title: '卡状态', width:120 ,
                    templet:function (d) {
                        const card_status= d.card_status;
                        var   html  =   '';
                        switch (card_status) {
                            case 1:
                                html = "<span style='color: green'>ACTIVE</span>";
                                break;
                            case 2:
                                html = "<span style='color: #6c757d'>SUSPENDED</span>";
                                break;
                            case 3:
                                html = "<span style='color: red'>CLOSED</span>";
                                break;
                            case 4:
                                html = "<span style='color: red'>Fraud</span>";
                                break;
                        }
                        return html;
                    }
                },
                { field: 'card_num',  align: 'left', title: 'card_num',width: 180},
                { field: 'mcc',  align: 'left', title: 'mcc',width: 80},
                { field: 'key_name',  align: 'left', title: '关键字',width:150},
                {field: 'amount_auth', title: '预扣($)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:120,totalRow: true
                },
                {field: 'amount_post', title: '实扣($)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:120,totalRow: true
                },
                { field: 'status', title: '是否处理', width:120 ,
                    templet:function (d) {
                        const is_ok=   d.is_ok;
                        var   html  =   '';
                        switch (is_ok) {
                            case 0:
                                html = "<span style='color: red'>未处理</span>";
                                break;
                            case 1:
                                html = "<span style='color: green'>已处理</span>";
                                break;
                            case 2:
                                html = "<span style='color: #6c757d'>冻结用户</span>";
                                break;
                        }
                        return html;
                    }
                },
                { field: 'result',  align: 'center', title: 'result',width: 200},
                { align: 'center', title: '创建时间',width:180,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { align: 'center', title: '处理时间',width:180,
                    templet: function (d) {
                        if(d.utime != ''){
                            return layui.util.toDateString(d.utime * 1000, "yyyy-MM-dd HH:mm:ss");
                        }

                    }
                }
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>